package logic

import (
	"context"
	"tiktok/tiktokrpc/tiktokrpc"

	"tiktok/api/internal/svc"
	"tiktok/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type AuthLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAuthLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AuthLogic {
	return &AuthLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AuthLogic) Auth(req *types.AuthRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	login, err := l.svcCtx.Tiktokrpc.Auth(l.ctx, &tiktokrpc.AuthRequest{
		UserId: req.UserId,
		Name:   req.Name,
		IdCard: req.IdCard,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}
	return &types.Response{
		Message: "实名认证成功",
		Data:    login,
		Code:    200,
	}, nil
}
